//
//  CellOfSearchForUser.m
//  PetAPP
//
//  Created by apple on 16/2/25.
//  Copyright © 2016年 Yuming. All rights reserved.
//

#import "CellOfSearchForUser.h"
#import "ModelOfSearchUser.h"
#import <YYWebImage.h>

@interface CellOfSearchForUser ()

@property (nonatomic, retain) UIImageView *imageViewOfFace;

@property (nonatomic, retain) UIButton *buttonOfIsfollow;


@end

@implementation CellOfSearchForUser

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
     
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews {
    
    self.imageViewOfFace = [[UIImageView alloc] init];
    [self.contentView addSubview:_imageViewOfFace];
    [_imageViewOfFace release];
    
    self.labelOfName = [[UILabel alloc] init];
    [self.contentView addSubview:_labelOfName];
    [_labelOfName release];
    
    self.buttonOfIsfollow = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.contentView addSubview:_buttonOfIsfollow];
    
    self.buttonOfIsfollow.titleLabel.font = [UIFont systemFontOfSize:17];
    [self.buttonOfIsfollow setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
    self.buttonOfIsfollow.layer.cornerRadius = 4;
    self.buttonOfIsfollow.backgroundColor = [UIColor colorWithRed:1.0 green:0.8423 blue:0.2839 alpha:1.0];
    self.buttonOfIsfollow.layer.borderWidth = 0;
    [self.buttonOfIsfollow setTitle:@"✚ 关注" forState:UIControlStateNormal];
    

}

- (void)layoutSubviews {

    [super layoutSubviews];
    
    self.imageViewOfFace.frame = CGRectMake(10, 10, 50, 50);
    self.imageViewOfFace.layer.cornerRadius = 25;
    self.imageViewOfFace.layer.masksToBounds = YES;
    
    self.labelOfName.frame = CGRectMake(70, 20, 100, 30);
    
    self.buttonOfIsfollow.frame = CGRectMake(self.contentView.frame.size.width - (15 + 80), 20, 80, 30);

}

- (void)handleDataWithModel:(ModelOfSearchUser *)model {

//    self.imageViewOfFace.yy_imageURL = [NSURL URLWithString:model.userface];
    [self.imageViewOfFace yy_setImageWithURL:[NSURL URLWithString:model.userface] options:YYWebImageOptionProgressiveBlur | YYWebImageOptionSetImageWithFadeAnimation];

    
    self.labelOfName.text = model.username;



}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
